from django.http import JsonResponse
from AnalysisService.MMKeyUtil import API_RESULT_KEY

class DAResultNoraml:

    @staticmethod
    def getJson(code,data={},message=''):
        json = data
        response = JsonResponse({'code': code, API_RESULT_KEY: json, 'message': message}, safe=False)
        return response

    @staticmethod
    def success():
        return DAResultNoraml.getJson(200,message='成功')

    @staticmethod
    def successWithMessage(message):
        return DAResultNoraml.getJson(200,message=message)

    @staticmethod
    def successWithData(data):
        return DAResultNoraml.getJson(200,data=data)

    @staticmethod
    def error():
        return DAResultNoraml.getJson(40003,message='失败')

    @staticmethod
    def fail():
        return DAResultNoraml.getJson(40001,message='网络不给力')

    @staticmethod
    def failWithMessage(message):
        return DAResultNoraml.getJson(40002,message=message)


class DAResultCommon:

    @staticmethod
    def phoneNumberFail():
        return DAResultNoraml.getJson(40010,message='手机号有误')


    @staticmethod
    def dataFail():
        return DAResultNoraml.getJson(40012,message='请重新确认')


class DAResultCaptcha:

    @staticmethod
    def success():
        return DAResultNoraml.getJson(200,message='成功获取验证码')

    @staticmethod
    def checkSuccess():
        return DAResultNoraml.getJson(200,message='验证成功')

    @staticmethod
    def noticeSuccess():
        return DAResultNoraml.getJson(200,message='发送成功')

    @staticmethod
    def fail():
        return DAResultNoraml.getJson(40020,message='验证码获取失败')

    @staticmethod
    def checkFail():
        return DAResultNoraml.getJson(40021,message='请输入正确的手机号或验证码')

    @staticmethod
    def wait():
        return DAResultNoraml.getJson(40023,message='已获取，请稍后...')

    @staticmethod
    def timeout():
        return DAResultNoraml.getJson(40023,message='验证码已过期，请重新获取...')


class DAResultEntry:

    @staticmethod
    def entryError():
        return DAResultNoraml.getJson(50001,message='您已报名')